/**  
* Copyright (c) 2009, Noel Lynch All rights reserved. Redistribution and use  
* in source and binary forms, with or without modification, are permitted  
* provided that the following conditions are met: Redistributions of source  
* code must retain the above copyright notice, this list of conditions and the  
* following disclaimer. Redistributions in binary form must reproduce the above  
* copyright notice, this list of conditions and the following disclaimer in the  
* documentation and/or other materials provided with the distribution. Neither  
* the name of Noel Lynch nor the names of contributors may be used to  
* endorse or promote products derived from this software without specific prior  
* written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT  
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A  
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR  
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;  
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR  
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF  
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
*/
// created by noellynch
// Sep 3, 2009

package com.sceneworker.editors.glslshadereditor.shadersnippets;

import java.util.ArrayList;

import com.sceneworker.editors.glslshadereditor.uniformreps.Float1Rep;
import com.sceneworker.editors.glslshadereditor.uniformreps.Int1Rep;
import com.sceneworker.editors.glslshadereditor.uniformreps.Mat3Rep;
import com.sceneworker.editors.snippets.Snippet;
import com.sceneworker.editors.snippets.SnippetManager;

public final class ShaderSnippetManager extends SnippetManager {

	static	private		ShaderSnippetManager		mcl_inst;
	
	static	public		ShaderSnippetManager		inst() {
		if(mcl_inst == null) {
			mcl_inst = new ShaderSnippetManager();
		}
		
		return mcl_inst;
	}
	
	private		ShaderSnippetManager() {
		initialiseSnippets();
	}
	
	@Override
	public	void	initialiseSnippets() {
		mcla_snippets = new ArrayList<Snippet>();
		
		// basic texture
		ShaderSnippet		lcl_texure = new ShaderSnippet("Basic Texture Shader", "basicTexture", "basicTexturing");
		lcl_texure.addUniformInfo(new UniformInfo("sceneTexture", Int1Rep.NAME));
		mcla_snippets.add(lcl_texure);
		
		// diffuse fragment
		mcla_snippets.add(new ShaderSnippet("Diffuse Lighting Fragment Shader", "diffuseFragment", "diffuseFragmentShader"));
		
		// diffuse fragment with texture
		ShaderSnippet		lcl_texureWithFragment = new ShaderSnippet("Basic Texture With Diffuse Fragment Shader", "diffuseFragmentWithTexture", "textureDiffuseFragmentLightingShader");
		lcl_texureWithFragment.addUniformInfo(new UniformInfo("theTexture", Int1Rep.NAME));
		mcla_snippets.add(lcl_texureWithFragment);
		
		// diffuse + spec vertex
		ShaderSnippet		lcl_diffuseSpecVertex = new ShaderSnippet("Diffuse + Specular Lighting Vertex Shader", "diffuseSpecularVertex", "diffuseSpecularVertexShader");
		lcl_diffuseSpecVertex.addUniformInfo(new UniformInfo("specularExponent", Float1Rep.NAME));
		mcla_snippets.add(lcl_diffuseSpecVertex);
		
		// diffuse vertex
		mcla_snippets.add(new ShaderSnippet("Diffuse Lighting Vertex Shader", "diffuseVertex", "diffuseVertexShader"));
		
		// grey scale
		mcla_snippets.add(new ShaderSnippet("GreyScale Shader", "greyscale", "greyScale"));
		
		// inversion
		mcla_snippets.add(new ShaderSnippet("Inversion Shader", "inversion", "inversion"));
		
		// ambient occlusion
		mcla_snippets.add(new ShaderSnippet("Ambient Occlusion", "simpleao", "ao2"));
		
		// kernel filter
		ShaderSnippet		lcl_kernelFilter = new ShaderSnippet("Convolution Kernel Filter Fragment Shader", "kernelFilterFragment", "kernelFilterShader");
		lcl_kernelFilter.addUniformInfo(new UniformInfo("sceneTexture", Int1Rep.NAME));
		lcl_kernelFilter.addUniformInfo(new UniformInfo("weights", Mat3Rep.NAME));
		lcl_kernelFilter.addUniformInfo(new UniformInfo("weightSum", Float1Rep.NAME));
		mcla_snippets.add(lcl_kernelFilter);
		
		// mean blur
		ShaderSnippet		lcl_meanBlur = new ShaderSnippet("Mean Blur Shader", "meanBlurFragment", "basicMeanBlurShader");
		lcl_meanBlur.addUniformInfo(new UniformInfo("sceneTexture", Int1Rep.NAME));
		mcla_snippets.add(lcl_meanBlur);
		
		// alpha texture combined
		ShaderSnippet		lcl_alphaCombined = new ShaderSnippet("Texture Combined With Alpha Texture", "alphaTextureCombined", "alphaCombined");
		lcl_alphaCombined.addUniformInfo(new UniformInfo("theTexture", Int1Rep.NAME));
		lcl_alphaCombined.addUniformInfo(new UniformInfo("alphaTexture", Int1Rep.NAME));
		mcla_snippets.add(lcl_alphaCombined);
		
		// normal map with no specular hilights
		ShaderSnippet		lcl_normalMapNoSpec = new ShaderSnippet("Normal Map No Specular", "normalMapNoSpecularWithAttrs", "normalMapNoSpecularWithAttrs");
		lcl_normalMapNoSpec.addUniformInfo(new UniformInfo("baseMap", Int1Rep.NAME));
		lcl_normalMapNoSpec.addUniformInfo(new UniformInfo("normalMap", Int1Rep.NAME));
		mcla_snippets.add(lcl_normalMapNoSpec);
		
		// normal map with specular hilights
		ShaderSnippet		lcl_normalMapSpec = new ShaderSnippet("Normal Map With Specular", "normalMapSpecularWithAttrs", "normalMapSpecAttrs");
		lcl_normalMapSpec.addUniformInfo(new UniformInfo("baseMap", Int1Rep.NAME));
		lcl_normalMapSpec.addUniformInfo(new UniformInfo("normalMap", Int1Rep.NAME));
		lcl_normalMapSpec.addUniformInfo(new UniformInfo("specularMap", Int1Rep.NAME));
		mcla_snippets.add(lcl_normalMapSpec);
		
		// pastel vertex
		mcla_snippets.add(new ShaderSnippet("Pastel Shader", "pastel", "pastelShader"));
		
		// sepia vertex
		mcla_snippets.add(new ShaderSnippet("Sepia Shader", "sepia", "sepia"));
	}
}
